package game.commands.app
{
	import game.commands.net.SCMD_502;
	import game.define.ProtocolDefine;
	
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	import utiles.net.NetworkManager;
	import utiles.net.QProtocol;
	
	public class InitNetDataProcessorCommand extends SimpleCommand
	{
		public function InitNetDataProcessorCommand()
		{
			super();
		}
		
		override public function execute(notification:INotification):void
		{
			var net:NetworkManager = NetworkManager.instance;
			net.setDataHandler(processorFunc);
			
			registerProtocol(ProtocolDefine.USER_INFO_RESP, SCMD_502);
		}
		
		private function registerProtocol(protocol:int, command:Class):void
		{
			facade.registerCommand(QProtocol.getName(protocol), command);
		}
		
		private function processorFunc(proto:QProtocol):void
		{
			facade.sendNotification(QProtocol.getName(proto.type), proto);
		}
	}
}